package day_2022_4_to_7.day48;

import java.util.Scanner;

/**
 * @author haomin
 * @date 2022/05/16 08:38
 **/
public class Day19_1_FindWaterBottle {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int num = in.nextInt();
            if(num <= 0){
                return;
            }
            System.out.println(findWaterBottle(num));
        }
    }

    private static int findWaterBottle(int num) {
        if (num == 2) {
            return 1;
        }
        if (num == 1) {
            return 0;
        }
        return num / 3 + findWaterBottle(num % 3 + num / 3);
    }
}